<template>
  <div>
    <el-card>
      <el-table :data="perList" style="width: 100%; margin-top: 20px" border>
        <el-table-column label="序号" type="index" align="center" width="50px" />
        <el-table-column label="权限名称" prop="name" align="center" />
        <el-table-column label="权限路径" prop="path" align="center" />
        <el-table-column label="权限等级" align="center">
          <template v-slot="{row}">
            <el-tag v-if="row.level === 1">一级权限</el-tag>
            <el-tag v-else type="success">二级权限</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { menu } from '@/api/menu'
export default {
  name: 'PerList',
  data() {
    return {
      perList: []
    }
  },
  created() {
    this.getMenuList()
  },
  methods: {
    async getMenuList() {
      const res = await menu('list')
      if (res.code !== 200) return this.$message.error(res.msg)
      this.perList = res.data
    }
  }
}
</script>

<style scoped>
</style>
